<template>
	<view class="cover-black">
		<image class="cover-img" src="https://img1.baidu.com/it/u=488054824,781673712&fm=26&fmt=auto&gp=0.jpg"
			mode="widthFix"
			@longpress="actionSheet"
			></image>
	</view>
</template>

<script>
	export default {
		data() {
			return {

			}
		},
		onLoad(par) {
			console.log(par)
			// 通过API修改导航栏的属性
			uni.setNavigationBarColor({
				frontColor: "#ffffff",
				backgroundColor: "#000000"
			})
		},
		methods: {
			actionSheet(){
				uni.showActionSheet({
					itemList:["下载封面"],
					success:function(par){
						
						console.log(par)
						if(par.tapIndex== 0) {
							console.log("下载图片")
							uni.showLoading({
								title:"保存中..."
							})
							uni.downloadFile({
								url:"https://img1.baidu.com/it/u=488054824,781673712&fm=26&fmt=auto&gp=0.jpg",
								success:function(res){
									console.log(res)
									uni.saveImageToPhotosAlbum({
										filePath:res.tempFilePath,
										success:function(res){
											console.log('saveImageToPhotosAlbum',res)
											uni.showToast({
												title:"保存成功"
											})
										},
										complete:function(){
											uni.hideLoading()
										}
									})
								}
							})
						}
			
					}
				})
			}
		}
	}
</script>

<style>
	.cover-black {
		background-color: #000000;
		width: 100%;
		height: 100%;

		display: flex;
		flex-direction: column;
		justify-content: center;
		position: fixed;
	}

	.cover-img {
		align-self: center;
	}
</style>
